<template>
	<view class="" style="padding-top: 32rpx;">
		<view class="" v-html="condition" style="margin: 0 32rpx;">
			
		</view>
		<view class="" style="position: fixed;bottom:0;padding-bottom: 10rpx;width: 100%;background: #fff;">
			<view class="flex align-center justify-between" style="font-size: 32rpx;color: #fff;margin: 0 32rpx;">
				<view @click="submit(1)" class="flex align-center justify-center" style="width: 328rpx;height: 100rpx;border-radius: 50rpx;background: #ccc;">
					不同意
				</view>
				<view @click="submit(2)" class="flex align-center justify-center" style="width: 328rpx;height: 100rpx;border-radius: 50rpx;background: #C06F0C;">
					同意
				</view>
			</view>
		</view>
		<!-- 申请成功弹窗 -->
		<uni-popup ref="popup" type="center" backgroundColor="transparent">
			<view class="" style="border-radius: 32rpx;overflow: hidden;width: 552rpx;background: #fff;">
				<view class="" style="font-size: 30rpx;line-height: 50rpx;padding: 78rpx 32rpx 70rpx 32rpx;text-align: center;">
					<!-- 提交成功，请保持电话畅通，平台将在48小时内与您联系（休息日除外） -->
					已提交申请,请勿重复申请
				</view>
				<view @click="know" class="flex align-center justify-center"
					style="height: 100rpx;background: #EBBE87;font-size: 32rpx;color: #844902;font-weight: 700;">
					我知道了
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				condition:'',
			}
		},
		onLoad() {
			this.getCondition();
			this.$request({
				url: 'agent/agent_info',
				data: {
					user_id:uni.getStorageSync('userInfo').id,
				},
			}).then(res => {
				if(res.data.code==1){
					if(res.data.data==null){
						return false
					}else{
						this.$refs.popup.open();
					}
				}else{
					uni.showToast({
						title:res.data.msg,
						icon:'none'
					})
				}
			})
		},
		methods:{
			know(){
				uni.navigateBack({
					delta:1
				})
				this.$refs.popup.close();
			},
			// 获取成为服务商须知
			getCondition(){
				this.$request({
					url: 'common/config',
					data: {
						keyword:'agent',
					},
					method:'post'
				}).then(res => {
					if(res.data.code==1){
						this.condition = res.data.data;
					}else{
						uni.showToast({
							title:res.data.msg,
							icon:'none'
						})
					}
				})
			},
			submit(e){
				if(e==1){
					// 不同意
					uni.navigateBack({
						delta:1
					})
				}else{
					//同意
					if(!uni.getStorageSync('userInfo').id){
						uni.showToast({
							title:'请登录',
							icon:'none'
						})
						return;
					}
					this.$request({
						url: 'agent/agent_info',
						data: {
							user_id:uni.getStorageSync('userInfo').id,
						},
					}).then(res => {
						console.log(res)
						if(res.data.code==1){
							if(res.data.data==null){
								uni.navigateTo({
									url:'/pages/news/sanqi/chengweifuwushang2'
								})
							}else{
								this.$refs.popup.open();
							}
						}else{
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
						}
					})
				}
			}
		}
	}
</script>

<style>
</style>